package com.cl.advice;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import com.cl.entity.Image;
import com.cl.entity.common.DBObject;
import com.cl.service.FileService;

@Component
@Aspect 
public class AdviceImage {

	private final static Log log = LogFactory.getLog(AdviceImage.class);
	
	@AfterReturning(pointcut="AdvicePay.aspectDelete() && args(entity, description, userId,ip)")
	public void updateImageSet(DBObject entity, String description, String userId, String ip)
	{
		// 删除影像时更新fileService中的imageSet
		//if (request.entity.equals("Image")) {
		if(entity.getClass().getName().contains("Image"))
		{
			Image img = (Image) entity;
			String cdlabel = img.getCdlabel();
			String imgFile = img.getImgFile();
			// 忽略外部导入影像
			if (cdlabel != null && imgFile != null
					&& !cdlabel.startsWith("Y")) {

				String infoStr = cdlabel.trim()
						+ imgFile.trim().toLowerCase();
				synchronized (FileService.imageSet) {
					FileService.imageSet.remove(infoStr);
				}
			}
		}
	}
	
	
	
	
}
